<template>
	<view class="">
		<e-popup mode="top" :safeAreaInsetBottom="false" :closeOnClickOverlay="true" round="32rpx" bgColor="#f8f8f8"
			:show="show" @close="close">
			<view class="all-box" :style="{'margin-top':  marginTop}">
				<view class="type-lefy">
					<scroll-view scroll-y="true">
						<view :class="{ 'left-active': item.id == leftCurrent }"
							v-for="(item, index) in oneClassifyList" :key="item.id" @tap="handleClickOne(item,index)">
							{{item.name}}</view>
					</scroll-view>
				</view>
			</view>
		</e-popup>
	</view>
</template>

<script>
	export default {
		props: {
			show: {
				type: Boolean,
				default: false
			},
			oneClassifyList: Array,
			twoClassifyList: Array,
			marginTop: String,
			value: Number
		},
		data() {
			return {
				leftCurrent: null,
				rightCurrent: null
			};
		},
		watch: {
			value: {
				handler(val) {
					if (val) {
						this.leftCurrent = val
					}
				},
				immediate: true
			}
		},
		methods: {
			close() {
				this.$emit("close", this.show)
			},
			handleClickOne(item, index) {
				this.leftCurrent = item.id
				this.$emit('select', item,index)
				this.close()
				// if (index) {
				// 	this.leftCurrent = item.id
				// } else {
				// 	this.$emit('select', item)
				// 	this.close()
				// }
				// this.$emit('change', item.id)
			},
			handleClickTwo(item, index) {
				this.rightCurrent = item.id
				this.$emit('select', item)
				this.close()
			},
		}
	};
</script>

<style scoped lang="scss">
	.all-box {
		height: 50vh;
		margin-top: 418rpx;
		display: flex;
		justify-items: center;

		.type-lefy {
			width: 250rpx;
			background: #F8F8F8;

			scroll-view {
				height: 100%;

				view {
					padding: 20rpx;
					font-size: 30rpx;
					color: #333333;
				}

				.left-active {
					color: #ff0000;
					background: #fff;
				}
			}
		}

		.type-right {
			flex: 1;
			background: #ffffff;
			border-bottom-right-radius: 32rpx;

			scroll-view {
				height: 100%;

				view {
					padding: 24rpx 20rpx;
					font-size: 30rpx;
					color: #333333;
				}

				.right-active {
					color: #ff0000;
				}
			}
		}
	}
</style>
